package com.example.prison.mapper;

import com.example.prison.entity.SystemLog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author jiang
* @description 针对表【system_log】的数据库操作Mapper
* @createDate 2023-06-12 15:57:49
* @Entity com.example.prison.entity.SystemLog
*/
@Mapper
public interface SystemLogMapper extends BaseMapper<SystemLog> {

    @Select("<script>select * from system_log " +
            " <where> " +
            " <if test=\"operator != null and operator != ''\">and operator like concat('%',#{operator},'%') </if> " +
            " <if test=\"beginTime != null and beginTime != ''\">and push_time &gt;= #{beginTime} </if> " +
            " <if test=\"endTime != null and endTime != ''\">and push_time &lt;= #{endTime} </if> " +
            " </where> " +
            "order by id desc</script>")
    List<SystemLog> get(@Param("operator") String operator,@Param("beginTime") String beginTime, @Param("endTime") String endTime);

    @Insert("insert into system_log(function, operation_time, operator) " +
            "values (#{function}, #{operationTime}, #{operator})")
    int add(SystemLog log);

    @Select("select * from system_log where id=#{id}")
    SystemLog getById(@Param("id") Integer id);

}




